
//  MyOrderCell.m
//  LoveFreshBeen
//
//  Created by vinsent on 16/10/16.
//  Copyright © 2016年 魏根. All rights reserved.
//

#import "MyOrderCell.h"
#import <UIImageView+WebCache.h>
#import "UIImageView+Extension.h"

@implementation MyOrderCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    [_textButton sizeToFit];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)drawRect:(CGRect)rect {
    
    UIBezierPath *path = [UIBezierPath bezierPathWithRect:self.bounds];
    
    CGFloat completTimeY = CGRectGetMaxY(_completTimeLable.frame);
    [path moveToPoint:CGPointMake(10, completTimeY + 7)];
    [path addLineToPoint:CGPointMake([UIScreen mainScreen].bounds.size.width, completTimeY + 7)];
   
    
    CGFloat imgMaxY = CGRectGetMaxY(_firstImg.frame);
    [path moveToPoint:CGPointMake(10, imgMaxY + 7)];
    [path addLineToPoint:CGPointMake([UIScreen mainScreen].bounds.size.width, imgMaxY + 7)];
    
    CGFloat butnumMaxY = CGRectGetMaxY(_buynumLable.frame);
    [path moveToPoint:CGPointMake(10, butnumMaxY + 7)];
    [path addLineToPoint:CGPointMake([UIScreen mainScreen].bounds.size.width, butnumMaxY + 7)];
    
    path.lineWidth = 0.5;
    [[UIColor lightGrayColor] set];
    
    [path stroke];
    
}

- (void)setOrderViewM:(OrderViewModel *)orderViewM {
    _orderViewM = orderViewM;
    _completTimeLable.text = orderViewM.myorderModel.completion_time;
    _textStatusLable.text = orderViewM.myorderModel.textStatus;
    _realamountLable.text = [NSString stringWithFormat:@"实付: $%.2f",[orderViewM.myorderModel.real_amount floatValue]];
    _buynumLable.text = [NSString stringWithFormat:@"共%@件商品",orderViewM.myorderModel.buy_num];
    [_textButton setTitle:orderViewM.myorderModel.buttons.firstObject.text forState:UIControlStateNormal];

    NSInteger count = orderViewM.myorderModel.order_goods.count;
    [_fivethImg setHidden:count < 5];
    NSArray *arr = @[_firstImg,_secondImg,_thirdImg,_fourthImg];
    for (int i = 0; i < count; i ++) {
        if (i == arr.count) {
            return;
        }
        [arr[i] setImageWithURLString:orderViewM.myorderModel.order_goods[i].img];
    }
    
    

}

@end
